#ifndef GPS_TRACK_H
#define GPS_TRACK_H

#include <QList>
#include <QString>
#include <QColor>
#include <QRectF>
#include <QHash>
#include "modifiable.h"
#include "gps_waypoint.h"
#include "gps_leg.h"

class GPS_track: public Modifiable
{
public:
    GPS_track();
    ~GPS_track();

    QList<int> listWaypoints() const;
    const GPS_waypoint* waypoint(int) const;
    GPS_waypoint* waypointMod(int);
    void waypointUpdated( GPS_waypoint* nwp = NULL);
    void deleteWaypoint( int );
    void addWaypoint(GPS_waypoint*);

    int id() const;

    QList<int> listLegs() const;
    const GPS_leg* leg(int) const;
    GPS_leg* legMod(int);
    void legUpdated(GPS_leg* nlg = NULL);
    void deleteLeg( int );
    bool addPointToLeg( GPS_point*, int leg_id);
    void dropLastPointFromLeg(int);
    int nLegs() const;
    void addLeg(GPS_leg*);

    int lineWidth() const;
    void setLineWidth(int);

    QString title() const;
    virtual void setTitle(const QString&);

    QString description() const;
    virtual void setDescription(const QString&);

    void setBoundingRect(const QRectF&);
    QRectF boundingRect() const;

    void clearTrack();

    int totalPoints() const;
    int totalLength() const;

protected:
    QRectF _boundingRect;
    int _totalPoints;
    int _totalLength;
    QHash<int, GPS_leg*> _legs;
    QHash<int, GPS_waypoint*> _waypoints;

    int _line_width;
    int _id;

    QString _title;
    QString _description;
    void expandBoundingRect( double lat, double lon );
};

#endif // GPS_TRACK_H
